$(function() {
	 $('#computeId').combobox({
			url:'../rule/getComputeRules2',
			valueField:'computeId',
			textField:'computeName',
			panelHeight:'auto'
		});
	$('#huodg13').datagrid({
		//请求地址
	    url:'../rule/getcheckRule',
	    columns:[[
	    	{field:'',title:'',checkbox:true},
			{field:'ruleId',title:'规则编号',width:'8%'},		
			{field:'computeId',title:'规则名称',width:'8%',
				formatter: function(value,row,index){
					if (row.checkComputeRule){
						return row.checkComputeRule.computeName;
					} else {
						return "";
					}
				}},
			{field:'clockIn',title:'上班打卡',width:'8%'},
			{field:'inbeginTime',title:'打卡时间',width:'15%'},
			{field:'inendTime',title:'结束时间',width:'15%'},
			{field:'clockLate',title:'迟到打卡',width:'8%'},
			{field:'latebeginTime',title:'打卡时间',width:'15%'},
			{field:'lateendTime',title:'结束时间',width:'15%'},
			{field:'earlyClock',title:'早退打卡',width:'8%'},
			{field:'earlybeginTime',title:'开始时间',width:'15%'},
			{field:'earlyendTime',title:'结束时间',width:'15%'},
			{field:'clockOut',title:'下班打卡',width:'8%'},
			{field:'outbeginTime',title:'开始时间',width:'15%'},
			{field:'outendTime',title:'结束时间',width:'15%'},
			{field:'remark',title:'备注',width:'10%'},
			{field:'maker',title:'创建者',width:'8%'},
			{field:'makeTime',title:'创建日期',width:'15%'}
			] ],
			onLoadSuccess : function() {
				$("#huoedit13").bind('click',function(){
					var rows = $('#huodg13').datagrid('getSelected');
					if(rows.ruleId!=null||rows.ruleId==""){
						$("#ruleId").val(rows.ruleId);
						$("#computeId").val(rows.checkComputeRule.computeName);
						$("#clockIn").val(rows.clockIn);
						$("#inbeginTime").timespinner('setValue',rows.inbeginTime);
						$("#inendTime").timespinner('setValue',rows.inendTime);
						$("#clockLate").val(rows.clockLate);
						$("#latebeginTime").timespinner('setValue',rows.latebeginTime);
						$("#lateendTime").timespinner('setValue',rows.lateendTime);
						$("#earlyClock").val(rows.earlyClock);
						$("#earlybeginTime").timespinner('setValue',rows.earlybeginTime);
						$("#earlyendTime").timespinner('setValue',rows.earlyendTime);
						$("#clockOut").val(rows.clockOut);
						$("#outbeginTime").timespinner('setValue',rows.earlybeginTime);
						$("#outendTime").timespinner('setValue',rows.earlyendTime);
						$("#remark").val(rows.remark);
						$("#maker").val(rows.maker);
						$("#makeTime").val(rows.makeTime);
						$("#huodd13").window("open");
					}else{
						alert("未勾选数据");
					}
				})
			},
	    fit:true,
	    //fit:true
	    fitColumns:true,
	    //隔行变色
	    striped:true,
	    nowrap:true,
	    //显示行号
	    rownumbers:true,
	    //设置单选
	    singleSelect:true,
		toolbar:'#huotb13',
		//显示分页栏
		pagination:true,
		//设置每页大小
		pageSize:5,
		//可选的每页大小
		pageList:[5,10,20,50]
	});
});
 function searchname(value){
	 $('#huodg13').datagrid('load','../rule/serchCheckRule?ruleName='+value);
} 
	function removeit(){
			var rows = $('#huodg13').datagrid('getSelections');
			if(rows.length > 0){
				$.messager.confirm('请确认','您确定要删除当前所有选中的项目吗？',function(r){
					if(r){
						var ruleIds = [];
						for(var i = 0; i < rows.length; i++){
							ruleIds.push(rows[i].ruleId)
						}
						var huo_rowData = JSON.stringify(ruleIds);
						alert(huo_rowData);
						$.ajax({
							url : "../rule/deleteCheckRule",
							data : {"jsondata" : huo_rowData},
							success : function(e) {
								if (e == "ok") {
	                               alert("删除成功");
	                               $('#huodg13').datagrid('load');
								}
							}
						});
					}
				 })
				}
	}
